<?php

namespace App\Constants;

/**
 * 薪资类型枚举
 * 定义各种薪资类型和计算方式
 */
class SalaryTypeEnum extends AbstractEnum
{
    // 薪资类型常量
    public const BASIC_SALARY = 'basic_salary';
    public const PERFORMANCE_BONUS = 'performance_bonus';
    public const OVERTIME_PAY = 'overtime_pay';
    public const ALLOWANCE = 'allowance';
    public const SUBSIDY = 'subsidy';
    public const COMMISSION = 'commission';
    public const PIECEWORK = 'piecework';
    public const YEAR_END_BONUS = 'year_end_bonus';
    public const SPECIAL_BONUS = 'special_bonus';

    /**
     * 获取所有枚举实例
     */
    public static function getAll(): array
    {
        return [
            new self('basic_salary', '基本工资', '固定月薪', '#28A745', 'money-bill', 1),
            new self('performance_bonus', '绩效奖金', '基于绩效的奖金', '#17A2B8', 'trophy', 2),
            new self('overtime_pay', '加班费', '加班工作报酬', '#FFC107', 'clock', 3),
            new self('allowance', '津贴', '各类补助津贴', '#6C757D', 'hand-holding-usd', 4),
            new self('subsidy', '补贴', '生活补贴', '#FD7E14', 'utensils', 5),
            new self('commission', '提成', '销售提成', '#DC3545', 'percentage', 6),
            new self('piecework', '计件工资', '按件计酬', '#E83E8C', 'cogs', 7),
            new self('year_end_bonus', '年终奖', '年度奖金', '#20C997', 'gift', 8),
            new self('special_bonus', '专项奖金', '特殊贡献奖金', '#6F42C1', 'star', 9),
        ];
    }

    /**
     * 获取固定薪资类型
     */
    public static function getFixedSalaryTypes(): array
    {
        return [
            self::BASIC_SALARY,
            self::ALLOWANCE,
            self::SUBSIDY,
        ];
    }

    /**
     * 获取绩效薪资类型
     */
    public static function getPerformanceSalaryTypes(): array
    {
        return [
            self::PERFORMANCE_BONUS,
            self::COMMISSION,
            self::YEAR_END_BONUS,
            self::SPECIAL_BONUS,
        ];
    }

    /**
     * 获取变动薪资类型
     */
    public static function getVariableSalaryTypes(): array
    {
        return [
            self::OVERTIME_PAY,
            self::PIECEWORK,
        ];
    }

    /**
     * 检查是否为固定薪资
     */
    public static function isFixedSalary(string $type): bool
    {
        return in_array($type, self::getFixedSalaryTypes());
    }

    /**
     * 检查是否为绩效薪资
     */
    public static function isPerformanceSalary(string $type): bool
    {
        return in_array($type, self::getPerformanceSalaryTypes());
    }

    /**
     * 检查是否为变动薪资
     */
    public static function isVariableSalary(string $type): bool
    {
        return in_array($type, self::getVariableSalaryTypes());
    }
}
